import {
  q as u,
  p as me,
  ap as he,
  X as H,
  f as ge,
  H as ye,
  av as j,
  aw as ve,
  k as t,
  l,
  m as a,
  ax as T,
  as as c,
  az as be,
  at as N,
  ay as De
} from "./index-30f27935.js";
import { d as xe, c as U } from "./order-e84dc57e.js";
function v(m) {
  return (
    typeof m == "function" ||
    (Object.prototype.toString.call(m) === "[object Object]" && !De(m))
  );
}
function Be(m) {
  const b = u([]),
    I = u([]),
    S = u([]),
    V = u([]),
    A = u({}),
    p = u(!0);
  u({}), me();
  const g = u(1),
    y = u(10),
    f = u([]),
    C = u(""),
    D = u(""),
    h = u(""),
    x = u(""),
    E = u(""),
    L = u(),
    k = he("reload"),
    Y = u("no"),
    J = u("nohide"),
    M = u([]),
    F = u(""),
    W = u(""),
    z = u(""),
    B = H({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    $ = H({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    q = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: () => Y.value == "no"
      },
      {
        label: "ID",
        prop: "order_id",
        minWidth: 80,
        formatter: ({ order_id: e }) => `1${e}`
      },
      {
        label: "用户ID",
        prop: "user_id",
        minWidth: 80,
        formatter: ({ user_id: e }) => `1${e}`
      },
      { label: "姓名", prop: "user_name", minWidth: 120 },
      { label: "手机号", prop: "user_phone", minWidth: 120 },
      {
        label: "地址",
        prop: "address",
        align: "left",
        minWidth: 600,
        hide: () => J.value != "hideAddress"
      },
      {
        label: "商品名称",
        prop: "wares_name",
        minWidth: 250,
        formatter: ({
          wares_name: e,
          store_name: s,
          store_code: d,
          notes: r,
          activity: o,
          remarks: i,
          size: n
        }) =>
          t("div", null, [
            t("div", null, [e]),
            s
              ? t(
                  l("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  v(s) ? s : { default: () => [s] }
                )
              : "",
            d
              ? t(
                  l("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [a("门店码:"), d] }
                )
              : "",
            t("div", null, [
              r
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    v(r) ? r : { default: () => [r] }
                  )
                : ""
            ]),
            t("div", null, [
              o == 1
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [a("已赠送")] }
                  )
                : ""
            ]),
            t("div", null, [
              i
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    v(i) ? i : { default: () => [i] }
                  )
                : ""
            ]),
            t("div", null, [
              n
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    v(n) ? n : { default: () => [n] }
                  )
                : ""
            ])
          ])
      },
      { label: "产品金额", prop: "wares_price", minWidth: 100 },
      {
        label: "支付金额",
        prop: "pay_price",
        minWidth: 100,
        formatter: ({ pay_price: e }) =>
          t("div", { style: "color:#59AB74" }, [e])
      },
      { label: "积分折扣", prop: "hock_price", minWidth: 100 },
      { label: "折扣支付", prop: "other_price", minWidth: 100 },
      {
        label: "支付方式",
        prop: "pay_type",
        minWidth: 80,
        formatter: ({ pay_type: e }) => {
          if (e == 1) return "积分";
          if (e == 2) return "微信";
          if (e == 3) return "支付宝";
          if (e == 4) return "复消积分";
        }
      },
      {
        label: "内含数量",
        prop: "all_bottle",
        minWidth: 100,
        formatter: ({ all_bottle: e, wares_unit: s }) => e + s
      },
      {
        label: "状态",
        prop: "status",
        minWidth: 100,
        formatter: ({ status: e, track_name: s }) => {
          if (e == 1)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "", effect: "light" },
              { default: () => [a("待发货")] }
            );
          if (e == 2)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "", effect: "light" },
              { default: () => [a("待自提")] }
            );
          if (e == 7)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("在线支付积分不足")] }
            );
          if (e == 8)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("奖励发放中")] }
            );
          if (e == 9)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("待发放奖励")] }
            );
          if (e == 3 && s != "自提")
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("已快递")] }
            );
          if (e == 3 && s == "自提")
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("已自提")] }
            );
        }
      },
      {
        label: "下单时间",
        minWidth: 180,
        prop: "add_time",
        formatter: ({ add_time: e }) => T(e * 1e3).format("YYYY-MM-DD HH:mm:ss")
      },
      { label: "操作", fixed: "right", width: 250, slot: "operation" }
    ],
    X = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "用户ID", prop: "user_id", minWidth: 80 },
      { label: "订单ID", prop: "order_id", minWidth: 80 },
      { label: "收件人手机号", prop: "user_phone", minWidth: 120 },
      { label: "收件人姓名", prop: "user_name", minWidth: 120 },
      { label: "收件人地址", prop: "address", minWidth: 150 },
      { label: "商品信息", prop: "wares", minWidth: 150 },
      { label: "订单编号", prop: "order_code", minWidth: 150 },
      { label: "支付金额", prop: "pay_price", minWidth: 100 },
      {
        label: "状态",
        prop: "status",
        minWidth: 100,
        formatter: ({ status: e, track_name: s }) => {
          if (e == 1)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("待发货")] }
            );
          if (e == 2)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("待自提")] }
            );
          if (e == 7)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("在线支付积分不足")] }
            );
          if (e == 8)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("奖励发放中")] }
            );
          if (e == 9)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("待发放奖励")] }
            );
          if (e == 3 && s != "自提")
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("已快递")] }
            );
          if (e == 3 && s == "自提")
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("已自提")] }
            );
        }
      },
      { label: "内含几瓶", prop: "all_bottle", minWidth: 100 },
      { label: "单位", prop: "wares_unit", minWidth: 100 },
      { label: "门店码", prop: "store_code", minWidth: 100 },
      { label: "门店名称", prop: "store_name", minWidth: 100 },
      {
        label: "下单时间",
        minWidth: 180,
        prop: "add_time",
        formatter: ({ add_time: e }) => T(e * 1e3).format("YYYY-MM-DD HH:mm:ss")
      },
      { label: "衣服规格", prop: "size", minWidth: 100 },
      { label: "订单备注", prop: "remarks", minWidth: 100 },
      { label: "备注", prop: "notes", minWidth: 100 },
      { label: "操作", fixed: "right", width: 250, slot: "operation" }
    ],
    G = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "id", minWidth: 80 },
      { label: "订单ID", prop: "order_id", minWidth: 80 },
      { label: "用户名", prop: "user_name", minWidth: 150 },
      {
        label: "身份",
        prop: "user_place",
        minWidth: 100,
        formatter: ({ user_place: e }) => {
          if (e == 0)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("暂无")] }
            );
          if (e == 1)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("一星合伙人")] }
            );
          if (e == 2)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("二星合伙人")] }
            );
          if (e == 3)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("三星合伙人")] }
            );
          if (e == 4)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("四星合伙人")] }
            );
          if (e == 5)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("五星合伙人")] }
            );
          if (e == 6)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("一星联创")] }
            );
          if (e == 7)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("二星联创")] }
            );
          if (e == 8)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("三星联创")] }
            );
          if (e == 9)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("四星联创")] }
            );
          if (e == 10)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("一星董事")] }
            );
          if (e == 11)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("二星董事")] }
            );
          if (e == 12)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("三星董事")] }
            );
        }
      },
      { label: "手机号", prop: "user_phone", minWidth: 120 },
      {
        label: "积分",
        prop: "income",
        minWidth: 100,
        formatter: ({ income: e, money: s }) => e || s
      },
      {
        label: "状态",
        prop: "status",
        minWidth: 100,
        formatter: ({ status: e }) => {
          if (e == 1)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("已发放")] }
            );
          if (e == 2)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "info", effect: "light" },
              { default: () => [a("未发放")] }
            );
        }
      },
      { label: "类型", prop: "type_name", minWidth: 100 },
      { label: "来源用户", prop: "source_name", minWidth: 150 },
      { label: "来源用户手机号", prop: "source_phone", minWidth: 120 }
    ],
    K = ge(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function Q(e) {
    const s = { order_id: e.order_id },
      d = JSON.stringify(s),
      o = { value: c.enc.Base64.stringify(c.enc.Utf8.parse(d)) },
      i = await xe(o);
    i.code == 200 &&
      ((I.value = i.data.income),
      (S.value = i.data.dispel),
      (V.value = i.data.freeze),
      (A.value = i.data.indent));
  }
  async function Z(e) {
    be(e);
  }
  async function P(e) {
    const s = { id: e.id },
      d = JSON.stringify(s),
      o = { value: c.enc.Base64.stringify(c.enc.Utf8.parse(d)) },
      i = await questionDelete(o);
    i.code == 200
      ? (N("删除成功", { type: "success" }), k())
      : N(i.msg, { type: "error" });
  }
  function ee() {}
  function te(e) {
    (y.value = e), _(void 0, e);
  }
  function le(e) {
    (g.value = e), _(e, void 0);
  }
  function ae(e) {
    M.value = e;
  }
  function se(e) {
    ($.text = `正在加载第${e}页...`),
      (p.value = !0),
      j(600).then(() => {
        p.value = !1;
      });
  }
  async function ue(e, s, d = [], r, o, i, n, ne, w, O) {
    (f.value = []),
      d.map(ce => {
        const fe = ce,
          pe = new Date(fe);
        f.value.push(
          pe.toLocaleDateString("zh-CN", {
            year: "numeric",
            month: "2-digit",
            day: "2-digit"
          })
        );
      }),
      (p.value = !0),
      (L.value = e),
      (C.value = o),
      (D.value = r),
      (h.value = s),
      (x.value = i),
      (E.value = n),
      (F.value = ne),
      (W.value = w),
      (z.value = O);
    const re = {
        page: g.value,
        pagesize: y.value,
        status: 1,
        user_phone: isNaN(s) ? void 0 : s,
        user_id: isNaN(r) ? void 0 : r,
        user_name: isNaN(s) ? s : void 0,
        order_code: i || void 0,
        name_phone: n || void 0,
        start: f.value[0],
        end: f.value[1],
        store_code: o,
        sort: F.value == "address" ? "address" : void 0,
        wares_unit: w == "no" ? void 0 : w,
        all_bottle: O || void 0,
        action: "add_time"
      },
      de = JSON.stringify(re),
      oe = { value: c.enc.Base64.stringify(c.enc.Utf8.parse(de)) },
      { data: R } = await U(oe);
    (b.value = R.indent.data),
      (B.total = R.indent.total),
      setTimeout(() => {
        p.value = !1;
      }, 500);
  }
  async function _(e = g.value, s = y.value) {
    const d = {
        page: e,
        pagesize: s,
        status: "1",
        user_phone: isNaN(h.value) ? void 0 : h.value,
        user_id: isNaN(D.value) ? void 0 : D.value,
        user_name: isNaN(h.value) ? h.value : void 0,
        order_code: x.value ? x.value : void 0,
        name_phone: E.value ? E.value : void 0,
        start: f.value[0],
        end: f.value[1],
        store_code: C.value,
        sort: F.value == "address" ? "address" : void 0,
        wares_unit: W.value == "no" ? void 0 : W.value,
        all_bottle: z.value || void 0,
        action: "add_time"
      },
      r = JSON.stringify(d),
      i = { value: c.enc.Base64.stringify(c.enc.Utf8.parse(r)) },
      n = await U(i);
    n.code === 200
      ? ((b.value = n.data.indent.data),
        (B.total = n.data.indent.total),
        setTimeout(() => {
          p.value = !1;
        }, 500))
      : N(n.msg, { type: "error" });
  }
  const ie = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    ye(() => {
      j().then(() => {
        const { setWatermark: e } = ve(m.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        _();
    }),
    {
      loading: p,
      columns: q,
      dataList: b,
      userColumns: G,
      pagination: B,
      buttonClass: K,
      userDatilList: I,
      orderInfo: A,
      columnsTable: X,
      count: g,
      selectData: Y,
      hideVal: J,
      pageCount: y,
      formattedDate: f,
      typeCount: L,
      multipleSelection: M,
      userDatilListDisple: S,
      userDatilListFreeze: V,
      handleLookUserDatil: Q,
      onSearch: ue,
      resetForm: ie,
      handleaddUser: ee,
      handleUpdate: Z,
      handleDelete: P,
      handleSizeChange: te,
      handleCurrentChange: le,
      handleSelectionChange: ae,
      onCurrentChange: se
    }
  );
}
export { Be as useRole };
